/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import com.mysql.jdbc.Connection;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author 
 */
public class Conexao {
    
    public Connection abrirConexao() throws Exception{
        // Endereço do banco
        String url = "jdbc:mysql://localhost:3306/Hotelaria";
        //usuario
        String usuario = "root";
        //senha
        String senha = "password@2014";
        
        //Driver de conexão ao banco
        Class.forName("com.mysql.jdbc.Driver");
        Connection conexao = (Connection) DriverManager.getConnection(url, usuario, senha);
        return conexao;
    }
    
    public void fecharConexao(Connection conexao){
        try {
            conexao.close();
        } catch (SQLException ex) {
            Logger.getLogger(Conexao.class.getName()).log(Level.SEVERE, null, ex);
            
        }
    }
    
}
